$(function(){


    //取出当前的URL
    function GetUrl(){
        var ContrStr = window.location.href;
        var NewContrStr = ContrStr.split('/');
        //alert(NewContrStr);
        var str = '';
       for(var i = 0; i < NewContrStr.length; i++){

         
         if(NewContrStr[i] == 'index' || NewContrStr[i] == 'admin'){
            str += (NewContrStr[i] + '/');
                return str;
         }
         str += (NewContrStr[i] + '/');
       }
    }
    
    var AjaxUrl = GetUrl();
    // alert(1);
    //AJAX发送函数 提现同意
    function getWeather(Action,controller,withDraw_id,element_name,AjaxUrl){
        
        $.ajax({  

            datatype:"json",
                    type : "GET",  //提交方式  
                     // url : "http://localhost/AdminFrame/public/admin/" + controller +"/"+Action+controller,//路径 
                     url : AjaxUrl + '' + controller +"/"+Action,//路径 
                     //url : "http://localhost/AdminFrame/public/admin/Bill/withDrawSET",//路径 
                    //url : "http://localhost/AdminFrame/public/admin/user/"+Action+"cate",//路径 
                    data : {  
                        
                        "withDraw_id":withDraw_id,
                        "element_name":element_name

                    },//数据，这里使用的是Json格式进行传输  
                    success : function(result) {//返回数据根据结果进行相应的处理
                        
                        //alert("ok");
                        //转成json 字符串
                        var ResultJsonObject = $.parseJSON(result);
                        
                        
                        //var a = $('#content .weather_block > div > h3').html();
                        //alert(a);

                        var location = "<span class='fa  fa-map-marker'></span> "+ ResultJsonObject.cityname[0]+''+ResultJsonObject.cityname[1] +",中国";
                        var city = '<span class="fa  fa-map-marker"></span> '+ ResultJsonObject.cityname[0]+''+ResultJsonObject.cityname[1];
                        var now = ResultJsonObject.now[0]+'<sup>o</sup>';


                        $('#content .weather_block > div > h3').html(city);
                        $('#content .weather_block > div > h1').html(now);
                        $('#content .location > p').html(location);

                         var detail = ResultJsonObject.stateDetailed[0];
                         //alert(detail);
                         var WeatherCode = getWeatherCode(detail);

                         $('#content .weather_block .weather_block_view').html(WeatherCode);
                         //alert(a);
                        //WeatherArray['暴雨'] = ''     
                    },
                    error : function(result){
                        //alert("获取失败");
                    } 
                }); 
    }
    


    //alert(1);
    //提现审批同意
    $('input[name = agree]').click(function(){

        var withDraw_id = $(this).parent().siblings().first().html();

        var Action = "withDrawSET";
        var controller = "Bill";
        var element_name = "agree";
        getWeather(Action,controller,withDraw_id,element_name,AjaxUrl);
        alert('修改成功');
         location.reload();

    })
    //提现审批拒绝
    $('input[name = refuse]').click(function(){

        var withDraw_id = $(this).parent().siblings().first().html();

        var Action = "withDrawFAL";
        var controller = "Bill";
        var element_name = "refuse";
        getWeather(Action,controller,withDraw_id,element_name,AjaxUrl);
        alert('修改成功');
         location.reload();
    })
})